import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue')
  },
  {
    path: '/cate',
    name: 'cate',
    component: () => import('../views/cate.vue')
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import('../views/cart.vue')
  },
  {
    path: '/user',
    name: 'user',
    component: () => import('../views/user.vue')
  },
  {
    path: '/xiangqing/:id',
    name: 'Xiangqing',
    component: () => import('../views/Xiangqing.vue')
  },
  {
    path: '/order',
    name: 'order',
    component: () => import('../views/order.vue')
  },
  {
    path: '/address',
    name: 'address',
    component: () => import('../views/address.vue')
  },
  {
    path: '/addhome',
    name: 'addHome',
    component: () => import('../views/addHome.vue')
  },
  {
    path: '/orderList',
    name: 'orderList',
    component: () => import('../views/orderList.vue')
  },
  {
    path: '/test',
    name: 'Test',
    component: () => import('../views/Test.vue')
  },
  {
    path: '/children',
    name: 'Children',
    component: () => import(/* webpackChunkName: "about" */ '../components/Children.vue')
  },
  {
    path: '/',
    redirect: '/home'
  },
]
const router = createRouter({
  history: createWebHashHistory(), 
  routes
})
router.beforeEach((to, from, next) => {
  let arr = ["/home", "/cart", "/cate", "/user"]
  let index = arr.indexOf(to.path)
  if (index == -1) {
    // console.log("!=-1");
  }
  // console.log(to.path);
  next()
})
export default router